package com.luckzj.sec;

import com.luckzj.sec.bridge.AbstractBridge;
import com.luckzj.sec.bridge.HttpBridge;
import com.luckzj.sec.config.BridgeConfig;
import com.luckzj.sec.bridge.TcpBridge;
import com.luckzj.sec.config.BridgeConfigReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Hello world!
 */
public class TcpBridgeServerApp {
    private static Logger logger = LoggerFactory.getLogger(TcpBridgeServerApp.class);

    public static void main(String[] args) {

        BridgeConfigReader bridgeConfigReader = new BridgeConfigReader();
        BridgeConfig[] configs = bridgeConfigReader.readConfigs();

        for (BridgeConfig config: configs) {
            AbstractBridge bridge;
            if ("http".equals(config.getProtocol())) {
                bridge = new HttpBridge(config);
            }
            else {
                bridge = new TcpBridge(config);
            }

            bridge.startBridge();
        }
    }
}
